package com.oop.ch01;

import java.util.Arrays;

public class Test {
	public static void main(String[] args) {
		String str="abcde,abaacdare";
		System.out.println(str.replace("a", "w"));
	}
	
	public static void binarySeach() {
		int array[]={-27,35,62,11,25,88,39};
		Arrays.sort(array);
		int index = Arrays.binarySearch(array, 35);
		System.out.println(index);
		
	}
	public static void sort() {
		int array[]={-27,35,62,11,25,88,39};
		Arrays.sort(array);
		System.out.println(Arrays.toString(array));
	}
	public static int[] delete(int array[],int index) {
		int []newarray=new int[array.length-1];
		for (int i = 0; i < newarray.length; i++) {
			if(index>i){
				newarray[i] = array[i];
			} else {
				newarray[i] = array[i+1];
			}
		}
		return newarray;
	}
	public static int[] insert(int array[],int index, int value) {
		int []newarray=new int[array.length+1];
		for (int i = 0; i < newarray.length; i++) {
			if(index>i){
				newarray[i] = array[i];
			} else if (index==i) {
				newarray[i]=value;
			}else {
				newarray[i] = array[i-1];
			}
		}
		return newarray;
	}
	
	public static void t1() {
		int num1[]={1,2,3,4,5,6,7,8,9};
		int num2[]=new int[num1.length];
		for (int i = num1.length-1,j=0; i >=0 ; i--,j++) {
			num2[j]=num1[i];
		}
		System.out.println(Arrays.toString(num2));
		
	}
}
